<?php

//这里是验证邮箱和昵称的方法

namespace Home\Model;
use Think\Model;
class UserModel extends Model {

        //检验邮箱是否存在
        public function checkEmail($email){
            $sql = "select * from user where email='{$email}'";

            //执行
            $res = $this->query($sql);

            return $res;

        }

        //检验昵称是否存在
        public function checkNickName($nickname){
            $sql = "select * from user where nickname='{$nickname}'";

            $res = $this->query($sql);

            return $res;


        }



        //登录验证方法
        public function checkLogin($email,$password){
            //先加密
            $password = md5($password);

            //原生写法
            $sql = "select * from user where email='{$email}' and password='{$password}'";

            $res = $this->query($sql);

            return $res;

            //tp方法
            // $data = array('email'=>$email,'password'=>md5($password)); //先声明一个需验证字段的数组

            // return $this->where($data)->find();   //返回查询结果

        }
       
       
} 
